<?php

class Info_server extends CI_Controller {

	public function __construct(){
		parent::__construct();
	}
	
	public function index()	{
		echo("hola");
		/*
		$this->email->from('correderaverdejo@gmail.com', 'Mario');
		$this->email->to('correderaverdejo@gmail.com');
		
		$this->email->subject('Email Test');
		$this->email->message('Testing the email class.');
		
		$this->email->send();
		
		echo $this->email->print_debugger();
		$this->load->view('test/index');*/
	}
	
	public function listarBasesDatos(){
		$this->load->model('bbddDao');
		print_r($this->bbddDao->getBasesDeDatos());
	}
	
	public function listarTablasPorBaseDatos(){
		$this->load->model('bbddDao');
		$bbdd = $this->uri->segment(3);
		
		$tablas=$this->bbddDao->getTablasByBbdd($bbdd);
		
		$rows = array();
		for($i=0;$i<count($tablas);$i++){
			$rows[]= array(
					"id"=>$i,
					"text"=>$tablas[$i]['Tables_in_'.$bbdd]
			);
		}
		echo json_encode($rows);
	}
	
	public function listar_info_bases_datos_tree(){
		$this->load->model('bbddDao');
		$info = array();
		$listado_bbdd=$this->bbddDao->getBasesDeDatos();
		for($b=0;$b<count($listado_bbdd);$b++){
			$bbdd = $listado_bbdd[$b]['Database'];
			$info['bbdd'][$b] = $bbdd;
			$tablas = $this->bbddDao->getTablasByBbdd($bbdd);
			print_r($info);
			for($t=0;$t<count($tablas);$t++){
				$tabla = $tablas[$t]['Tables_in_'.$bbdd];
				echo($tabla."<br>");
			}
			
			//$info['bbdd'][$b]['tablas']=$tablas;
		}
		print_r($info);
		
	}
	
	
	function info_tabla_bbdd(){
		$this->load->view('info_server/info_tabla_bbdd');
	}
}

?>